#include "Ark.h"
#include "Animal.cpp"
Ark::Ark()
{
	this -> totalAnimals = 0;
	for (int i = 0; i <= MAXSIZE; ++i)
		this -> animals[i] = NULL;
}
void Ark::addAnimal(Animal *A)
{
	int i;
	if (this -> totalAnimals < MAXSIZE)
	{	
		for (i = 0; i < MAXSIZE; ++i)
			if (this -> animals[i] == NULL)
				break;
		this -> animals[i] = A;
		this -> totalAnimals += 1;
	}
	else
		printf("Limit exceded\n");	
}
std::ostream& operator << (std::ostream &out, Ark A)
{
	out << "There are " << A.totalAnimals << " animals on the ark.\n";
	for (int i = 0; i < A.totalAnimals; ++i)
	{
		A.animals[i] -> print();
		out << i << "\n";
	}
	return out;
}
void Ark::PassTime(int n)
{
	int i = 0, j;
	while (this -> animals[i] != NULL)
	{
		this -> animals[i] -> addAge(n);
		if (this -> animals[i] -> isFemale() && this -> animals[i] -> getAge() % 12 == 0)
			addAnimal(this -> animals[i] -> giveBirth());
		++i;
		if (i >= MAXSIZE)
			break;
	}
}
